// pages/face/face.js
const app = getApp()
Page({
  data: {
  },
  onLoad: function (res) {
  },
  record() {
    var fg= wx.createCameraContext()
    fg.takePhoto({
      quality: 'high', //高质量的图片
      // device-position:'front',
      success: res => {
        //res.tempImagePath照片文件在手机内的的临时路径
        let tempImagePath = res.tempImagePath
      //  this.callBackImg(tempImagePath)
      let img = wx.getFileSystemManager().readFileSync(tempImagePath, "base64")
      this.faceCheck(img)
      }
    })
  },
  faceCheck(str_img){
    let data = {base64Img:str_img}
    app.api.faceSearch(data).then(res => {
      if(res.data){
        app.globalData.userInfo.passwd = '123456'
        app.globalData.userInfo.loginid = res.data
        app.doLogin();
        // wx.switchTab({
        //     url: '/pages/menu/menu',
        //   })
      }else{
        wx.showModal({
          title: '提示',
          content: '人脸识别失败',
          showCancel:false,
          success(res) {
          }
        })
      }
    })
  }
})